#ifndef FKFILESLIST_H
#define FKFILESLIST_H

#include <QDataStream>
#include <QStringList>

#include "fkobjects_global.h"

struct FKFileInfo;
class QDir;

class FKOBJECTSSHARED_EXPORT FKFilesList{
public:
    FKFilesList();
    FKFilesList(const FKFilesList& other);
    FKFilesList(const QList<FKFileInfo> &list);
    bool saveToFile(QString path);
    static FKFilesList loadFromPlatformFolders(QDir appFolder);
    static FKFilesList loadFromFile(QString path);
    ~FKFilesList();
    int size() const;
    QString path(int pos) const;
    QStringList paths() const;
    QString name(int pos) const;
    QStringList names() const;
    QString version(int pos) const;
    QStringList versions() const;
    qint64 weight(int pos) const;
    QList<qint64> weights() const;
    quint8 osType(int pos) const;
    QList<quint8> osTypes() const;

    int find(QString fl,quint8 os) const;

    QMap<QString,QString> fileMap(/*QDir root*/);
    QMap<QString,QString> fileMapAbsolute(QDir root);
    void refreshWeights(QDir &root);

//	void setRootPath(QString rootPath);
    void addFile(QString name, QString version, QString relativePath, qint64 weight, quint8 osType);
    void addFile(int i, const FKFilesList &source);
    static void diff(FKFilesList &first, FKFilesList &second);
    static void compare(FKFilesList &first, FKFilesList &second);
    bool operator>=(const FKFilesList &other) const;
    bool operator<=(const FKFilesList &other) const;
    void operator+=(const FKFilesList &other);
    FKFilesList compare(const FKFilesList& other) const;    //return new with this names + other names + other values
    FKFilesList filter(quint8 osType) const;
    friend QDataStream& operator<<(QDataStream& stream, const FKFilesList& lst);
    friend QDataStream& operator>>(QDataStream& stream, FKFilesList& lst);
private:
//	QString _rootPath;
    int _size;
    QStringList _paths;
    QStringList _names;
    QStringList _versions;
    QList<qint64> _weights;
    QList<quint8> _osTypes;

    static int sId;
    static int declareFKMetaType();
};
Q_DECLARE_METATYPE(FKFilesList)

#endif // FKFILESLIST_H
